package com.mmg.controller;

import com.mmg.entity.User;
import com.mmg.common.Result;
import com.mmg.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户登录
 */
@RestController
@CrossOrigin
public class UserController {

    @Autowired
    UserService userService;

    @PostMapping("/login")
    public Result login(String username, String password) {
        User login = userService.login(new User(username, password));
        return Result.ok().data("token", login);
    }
}
